<template>
    <div>
        <!--点击弹窗-->
        <el-dropdown trigger="hover" class="dropdownitem-pic">
            <el-avatar :size="45" :src=ServeUrl+user.userimg ></el-avatar>
            <el-dropdown-menu slot="dropdown">
                <el-dropdown-item class="clearfix">
                    <router-link to="FuturePart">
                        <i class="el-icon-s-custom" @click="test">个人信息</i>
                    </router-link>
                </el-dropdown-item>
                <el-dropdown-item class="clearfix">
                    <router-link to="UserOrder">
                        <i class="el-icon-goods">我的订单</i>
                    </router-link>
                </el-dropdown-item>
                <el-dropdown-item class="clearfix">
                    <router-link to="FuturePart">
                        <i class="el-icon-star-off">我的收藏</i>
                    </router-link>
                </el-dropdown-item>
                <el-dropdown-item class="clearfix">
                    <router-link to="FuturePart">
                        <i class="el-icon-tickets">消息</i>
                    </router-link>
                </el-dropdown-item>
                <el-dropdown-item class="clearfix">
                    <router-link to="FuturePart">
                        <i class="el-icon-headset">客户服务</i>
                    </router-link>
                </el-dropdown-item>
                <el-dropdown-item class="clearfix">
                    <div @click="exit">
                        <i class="el-icon-s-promotion">
                            <span >退出</span>
                        </i>
                    </div>
                </el-dropdown-item>
            </el-dropdown-menu>
        </el-dropdown>
        <el-dropdown trigger="hover" class="dropdownitem">
            <el-button size="small" class="el-dropdown-link" v-text=user.username>
            </el-button>
            <el-dropdown-menu slot="dropdown">
                <el-dropdown-item class="clearfix">
                    个人信息
                </el-dropdown-item>
                <el-dropdown-item class="clearfix" @click="exit">
                    <span @click="exit">退出</span>
                </el-dropdown-item>
            </el-dropdown-menu>
        </el-dropdown>
    </div>
    
</template>

<script>
    export default {

        data(){
          return{
              ServeUrl:this.$store.state.beginUrl,
              value:null,
              isLogin:false,
              user:{
                  username:'',
                  userid:'',
                  userimg:""
              },
          }
        },
        methods:{
            exit() {
                this.$emit("exittologin",this.value);
                sessionStorage.clear();
               // location.reload()
                this.$router.push('/');
            },
            test(){
            }
        },
        created(){
            let json=window.sessionStorage.getItem("user");
            let user=JSON.parse(json);
            this.user.username=user.uUsername;
            this.user.userid=user.uUserid;
            this.user.userimg=user.uImgpath;
        },
        updated() {
            var user = this.$store.state.user;
            console.log("支付用户");
            console.log(user);
            if (null!=user){
                this.user.username=user.uUsername;
                this.user.userid=user.uUserid;
                this.user.userimg=user.uImgpath;
            }
        },
        mounted() {

        }
    }
</script>

<style scoped>
    .item {
        float: left;
        margin-top: 12px;
        margin-left: 40px;
    }
    .dropdownitem-pic{
        float: left;
        margin-top: 5px;
        margin-left: 40px;
    }
    .dropdownitem{
        float: left;
        margin-top: 12px;
        margin-left: 20px;
    }

</style>